class GitDataTrees
  attr_accessor :github

  def initialize(github)
    @github = github
  end

  def getTree(repo, sha, recursive=FALSE, user=nil)
    username = user == nil ? @github.username : user
    url = 'repos/%s/%s/git/trees/%s' % [username, repo, sha]
    url = recursive ? '%s?recursive=1' % url : url
    @github.get(url)
  end

  def createTree(repo, tree, baseTree=nil, user=nil)
    username = user == nil ? @github.username : user
    params = {
        :base_tree => baseTree,
        :tree => tree
    }
    params = @github.removeEmptyParams(params)
    data = params.to_json
    @github.post('repos/%s/%s/git/trees' % [username, repo], data)
  end
end